package file;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * Created by wuzhao on 2017/6/9 0009.
 */
public class FileRead {

    public static String readTxt(String filePath){
        BufferedReader brname;
        try {
            brname = new BufferedReader(new FileReader(filePath));
            String line;
            StringBuffer sb = new StringBuffer();
            while ((line = brname.readLine()) != null) {
                sb.append(line);
            }
            brname.close();
            String txt = sb.toString();
            return StringUtils.isBlank(txt) ? null:txt;
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        String readTxt = readTxt("C:/Users/Administrator/Desktop/temp3/temp/city/city.txt");
        JSONArray jsonArray = JSON.parseArray(readTxt);
        System.out.println("==="+jsonArray.size());
    }
}
